home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / vapnlm / ausvap.exe / PRELUDE.ASM < prev   
Assembly Source File  |  1991-07-23  |  15KB  |  425 lines

  1. comment !
  2.  
  3.     This software is provided as is and carries no warranty
  4.     whatsoever.  Novell disclaims and excludes any and all implied
  5.     warranties of merchantability, title and fitness for a particular
  6.     purpose.  Novell does not warrant that the software will satisfy
  7.     your requirements or that the software is without defect or error
  8.     or that operation of the software will be uninterrupted.  You are
  9.     using the software at your risk.  The software is not a product
  10.     of Novell, Inc. or any of subsidiaries.
  11.  
  12.     module:     prelude.asm     single process vap header.
  13.     abstract:   start up header and code for a VAP.
  14.     environ:    SFT NetWare v2.15 Rev C.
  15.  
  16.   
  17.     -------------------------------------------------------------
  18.     09/28/90    1.00    initial release.
  19.  
  20. !
  21.                 .model  large
  22.  
  23.                 name    VAPPrelude
  24.  
  25.                 .code
  26.  
  27.                 if  @codesize       ; if large model
  28.                     p   equ     6   ; first parm is 6 bytes away
  29.                 else
  30.                     p   equ     4   ; first parm is 4 bytes away
  31.                 endif
  32.  
  33.                 ;Public symbols for Novell NetWare C Interface for DOS libs
  34.  
  35.                 public  NetWareShellServices, ProcessControlServices
  36.                 public  ConsoleControlServices, IPXSPXServices
  37.  
  38. ;The following makes up the VAP Header.  It must be at the start of any VAP
  39.  
  40. Signature                       db      'NWProc'
  41. _NetWareShellServices           label   dword
  42. NetWareShellServices            dd      ?
  43. ProcessControlServices          dd      ?
  44. ConsoleControlServices          dd      ?
  45. IPXSPXServices                  dd      ?
  46. VAPConsoleHandler               dd      vConsoleHandler ; console handler func
  47. VAPDownHandler                  dd      vDownHandler    ; down handler function
  48. VAPConsoleOrDownDataSegment     dw      DGroup          ; con or down dataseg
  49. VAPConnectionRequestFlag        dw      0               ; give us default conn
  50. VAPName                         db      'A Sample NetWare VAP'
  51.                                 db      64-($-VAPName) dup(0)
  52. VAPConsoleKeyWordCount          dw      1               ; okay to set to zero
  53. VAPKeyw1                        db      'XX VAPKEYWORD' ;  if you remove these
  54.                                 db      16-($-VAPKeyw1) dup(0)  ; 2 lines!
  55. VAPSignOnMsg                    db      13,10
  56.                                 db      '┌─────────────────────────────┐',13,10
  57.                                 db      '│ NetWare Value Added Process │',13,10
  58.                                 db      '│ Sample VAP Header Source    │',13,10
  59.                                 db      '│ Version 0.10  ß  Revision A │',13,10
  60.                                 db      '└─────────────────────────────┘',13,10,13,10
  61.                                 db      500-($-VAPSignOnMsg) dup(0)
  62.  
  63. EO2READWRITE    equ     1                   ; execute/only to read/write
  64.  
  65. NetWareVAP      proc    far
  66.                 ;
  67.                 ;   All segments containing volatile data MUST be changed
  68.                 ;   to R/W!
  69.                 ;
  70.                 mov     ax, DGroup          ; our data segment
  71.                 mov     di, EO2READWRITE    ; change segment to read/write
  72.                 call    dword ptr cs:ProcessControlServices
  73.         if @datasize
  74.                 mov     ax, FAR_DATA        ; far data segment
  75.                 mov     di, EO2READWRITE    ; change segment to read/write
  76.                 call    dword ptr cs:ProcessControlServices
  77.                 mov     ax, FAR_BSS         ; far unitialized data segment
  78.                 mov     di, EO2READWRITE    ; change segment to read/write
  79.                 call    dword ptr cs:ProcessControlServices
  80.         endif
  81.                 ;
  82.                 ;   A 100 byte stack has been established for us by NetWare.
  83.                 ;   If you need a larger stack, do setup here.
  84.                 ;   
  85.                 ;   Establish initial addressability for all segments.
  86.                 ;
  87.                 cli                         ; don't interrupt me now!
  88.                 mov     ax, DGROUP          ; establish addressability
  89.                 mov     bx, OFFSET DGroup:MainStackEnd
  90.                 mov     ds, ax
  91.                 mov     es, ax
  92.                 mov     ss, ax
  93.                 mov     sp, bx              ; setup the stack for process#1
  94.                 sti                         ; allow interrupts now
  95.  
  96.                 ; main( WORD DataSegment, WORD CodeSegment );
  97.  
  98.                 push    cs                  ; pass code segment
  99.                 push    ds                  ; and data segment to process #1
  100.                 extrn   _main:proc
  101.                 call    _main               ; call process #1
  102.                 ;
  103.                 ; we should never get here!  But just in case...
  104.                 ;
  105.                 mov     ax,offset DGROUP:Oops$Msg
  106.                 push    ax
  107.         if @datasize
  108.                 push    ds
  109.         endif
  110.                 extrn   _ConsoleDisplay:proc    ;NetWare C Interface - DOS Lib
  111.                 call    far ptr _ConsoleDisplay
  112.  
  113.                 extrn   _SleepProcess:proc      ;NetWare C Interface - DOS Lib
  114. DeadLoop:       call    _SleepProcess
  115.                 jmp short DeadLoop          ; sleep forever
  116. NetwareVAP      endp
  117.  
  118. vConsoleHandler proc    far
  119.                 ;
  120.                 ;This procedure is called by NetWare when one of our keywords
  121.                 ;has been typed at the console.
  122.                 ;
  123.                 ;on entry:
  124.                 ;   AX - Keyword number typed at console
  125.                 ;   DS - Initialized to VAPConsoleOrDownDataSegment field
  126.                 ;   BX:SI - Points to command line
  127.                 ;
  128.  
  129.                 mov     cx,80               ; copy command line (it changes
  130.                 push    es                  ;  when a new command is entered)
  131.                 push    ds
  132.                 push    ds                  ; point es:di to our buffer
  133.                 pop     es
  134.                 mov     di,offset DGROUP:_CommandLine
  135.                 mov     ds,bx               ; ds:si source
  136.                 cld                         ; clear direction flag
  137.                 rep     movsb               ; xfer command line
  138.                 pop     ds                  ; restore registers & call handler
  139.                 pop     es
  140.  
  141.                 ; ConsoleHandler( WORD keyword );
  142.  
  143.                 push    ax                  ; pass to C function
  144.                 extrn   _ConsoleHandler:proc
  145.                 call    _ConsoleHandler     ; call C console handler
  146.                 add     sp,2                ; clean up the stack
  147.                 ret                         ; return to OS
  148. vConsoleHandler endp
  149.  
  150. vDownHandler    proc    far
  151.                 ;
  152.                 ;This procedure is called by NetWare when the 'DOWN' console
  153.                 ;command has been entered, before the server shuts down.
  154.                 ;
  155.                 ;on entry:
  156.                 ;   DS - Initialized to VAPConsoleOrDownDataSegment field
  157.                 ;
  158.                 extrn   _DownHandler:proc
  159.                 call    _DownHandler        ; call C down handler
  160.                 ret                         ; return to OS
  161. vDownHandler    endp
  162.  
  163. GETFILESRVNAME  equ     14h                 ; Request code for Get Server Name
  164.  
  165. NWCIV1_1 =  1
  166.  
  167. if        NWCIV1_1
  168.                 ;
  169.                 ;This function is needed only if you are using the v1.1
  170.                 ;NetWare C Interface functions.  v1.2 call is okay.
  171.                 ;
  172. _VAPGetFileServerName   proc
  173.                 public  _VAPGetFileServerName
  174.                 push    bp
  175.                 mov     bp,sp
  176.                 push    di                  ; save registers
  177.                 push    ds
  178.                 push    es
  179.                 push    si
  180.  
  181.             if @datasize
  182.                 les     si,p[bp]            ; point es:si to buffer
  183.             else
  184.                 push    ds                  ; point es to data segment
  185.                 pop     es
  186.                 mov     si,p[bp]            ; get offset of name buffer
  187.             endif
  188.                 mov     di, GETFILESRVNAME  ; function number
  189.                 call    dword ptr cs:[ProcessControlServices]   ; call OS
  190.  
  191.                 pop     si
  192.                 pop     es                  ; restore registers
  193.                 pop     ds
  194.                 pop     di
  195.                 pop     bp
  196.                 cbw                         ; return code in AX
  197.                 ret
  198. _VAPGetFileServerName   endp
  199.  
  200. endif   ;NWCIV1_1
  201.  
  202. ; int close(FHANDLE fh)
  203. _close PROC
  204.                 PUBLIC  _close
  205.                 PUSH    BP
  206.                 mov     BP, sp
  207.                 mov     BX, [BP+4]
  208.                 mov     ah,3Eh
  209.                 call    dword ptr cs:[NetWareShellServices]   ; call OS
  210.                 POP     BP
  211.                 RET
  212. _close ENDP
  213.  
  214.  
  215. ; FindFirst(char *fname);
  216. _FindFirst               proc
  217.                                                                 PUBLIC _FindFirst
  218.                 push   bp
  219.                 mov    bp,sp
  220.                 push   dx
  221.                 push   ds
  222.                 push   cx
  223.                 push   bx
  224.                 IF     @datasize
  225.                 lds    dx,[bp+p]
  226.                 ELSE
  227.                 mov    dx, [bp+p]
  228.                 ENDIF
  229.                 mov    cx,0
  230.                 mov    ah,4eh
  231.                 call   dword ptr cs:NetwareShellServices
  232.                 jc     FindBAD
  233.                 mov    ax,0
  234. FindBAD:
  235.                 pop    bx
  236.                 pop    cx
  237.                 pop    ds
  238.                 pop    dx
  239.                 pop    bp
  240.                 ret
  241. _FindFirst      endp
  242.  
  243. _SetDTA         PROC
  244.                 PUBLIC  _SetDTA
  245.                 push    bp
  246.                 mov     bp,sp
  247.                 PUSH    DS
  248.                 PUSH    DX
  249.           IF @datasize
  250.                 LDS     DX,[bp+p]
  251.           ELSE
  252.                 mov     dx,[bp+p]
  253.           ENDIF
  254.                 mov     ah,01ah
  255.                 call    cs:NetWareShellServices
  256.                 pop     dx
  257.                 pop     ds
  258.                 pop     bp
  259.                 ret
  260. _SetDTA         endp  
  261.  
  262.  
  263.  
  264.  
  265. ; FHANDLE open(char* pszPath, BYTE access)
  266. _open PROC
  267.                 PUBLIC  _open
  268.                 push    BP
  269.                 mov     BP, sp
  270.                 push    DS
  271.                 push    SI
  272.                 push    DI
  273.        if @datasize
  274.                 lds     DX, [BP+p]
  275.                 mov     al , byte ptr [BP+p+4]
  276.         else
  277.                 mov     DX, [BP+p]
  278.                 mov     al , byte ptr [BP+p+2]
  279.         endif
  280.                 mov     ah, 3Dh
  281.                 call    dword ptr cs:[NetWareShellServices]   ; call OS
  282.                 POP     DI
  283.                 POP     SI
  284.                 POP     DS
  285.                 POP     BP
  286.                 jnc     no_erroro
  287.                 mov     AX, 0FFFFh
  288.   no_erroro:
  289.                 RET
  290. _open ENDP
  291. ; FHANDLE create(char* pszPath, BYTE access)
  292. _create PROC
  293.                 PUBLIC  _create
  294.                 push    BP
  295.                 mov     BP, sp
  296.                 push    DS
  297.                 push    SI
  298.                 push    DI
  299.                 push    CX
  300.                 mov     CX,0
  301.        if @datasize
  302.                 lds     DX, [BP+p]
  303.                 mov     cl , byte ptr [BP+p+4]
  304.         else
  305.                 mov     DX, [BP+p]
  306.                 mov     cl , byte ptr [BP+p+2]
  307.         endif
  308.                 mov     ah, 3Ch
  309.                 call    dword ptr cs:[NetWareShellServices]   ; call OS
  310.                 POP     CX
  311.                 POP     DI
  312.                 POP     SI
  313.                 POP     DS
  314.                 POP     BP
  315.                 jnc     nc_erroro
  316.               ;  mov     AX, 0FFFFh
  317.   nc_erroro:
  318.                 RET
  319. _create ENDP
  320.  
  321.  
  322.  
  323.  
  324. ; int read(int handle, char *buff, int len)
  325. _read PROC
  326.                 PUBLIC  _read
  327.                 push    BP
  328.                 mov     BP, sp
  329.                 push    DS
  330.                 push    SI
  331.                 push    DI
  332.        if @datasize
  333.                 mov     BX ,[BP+p]
  334.                 lds     DX, [BP+p+2]
  335.                 mov     CX, [BP+P+6]
  336.         else
  337.                 MOV     BX, [BP+P]
  338.                 mov     DX, [BP+p+2]
  339.                 mov     CX, [BP+p+4]
  340.         endif
  341.                 mov     ah, 3Fh
  342.                 call    dword ptr cs:[NetWareShellServices]   ; call OS
  343.                 POP     DI
  344.                 POP     SI
  345.                 POP     DS
  346.                 POP     BP
  347.                 jnc     no_errorr
  348.                 mov     AX, 0FFFFh
  349.   no_errorr:
  350.                 RET
  351. _read ENDP
  352.  
  353. ; int write(int handle, char *buff, int len)
  354. _write PROC
  355.                 PUBLIC  _write
  356.                 push    BP
  357.                 mov     BP, sp
  358.                 push    DS
  359.                 push    SI
  360.                 push    DI
  361.        if @datasize
  362.                 mov     BX ,[BP+p]
  363.                 lds     DX, [BP+p+2]
  364.                 mov     CX, [BP+P+6]
  365.         else
  366.                 MOV     BX, [BP+P]
  367.                 mov     DX, [BP+p+2]
  368.                 mov     CX, [BP+p+4]
  369.         endif
  370.                 mov     ah, 40h
  371.                 call    dword ptr cs:[NetWareShellServices]   ; call OS
  372.                 POP     DI
  373.                 POP     SI
  374.                 POP     DS
  375.                 POP     BP
  376.                 jnc     no_errorr
  377.                 mov     AX, 0FFFFh
  378.   no_errorw:
  379.                 RET
  380. _write ENDP
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387. _VAPInterrupt3  proc                        ; for debugging
  388.                 ;
  389.                 ;This function is useful for debugging VAPs on a Real Mode
  390.                 ;bridge.  You can pass data that will be loaded into the
  391.                 ;registers before the break.  Passing a pointer to a
  392.                 ;"where am I" string is very useful here...
  393.                 ;
  394.                 public  _VAPInterrupt3
  395.                 push    bp
  396.                 mov     bp,sp
  397.                 mov     ax,[bp+p+0]         ; first parm in ax
  398.                 mov     bx,[bp+p+2]
  399.                 mov     cx,[bp+p+4]
  400.                 mov     dx,[bp+p+6]
  401.                 int     3h                  ; just pass control to debugger
  402.                 pop     bp
  403.                 ret                         ; back to C caller
  404. _VAPInterrupt3  endp
  405.  
  406.                 .data
  407.  
  408. Oops$Msg        label   byte
  409.                 db      'Oops!  I returned from main()!\n\r',0
  410.  
  411.                 public  _CommandLine
  412. _CommandLine    label   byte
  413.                 db      80 dup ( 0 )            ; buffer for command line
  414.  
  415.                 ;Process Stacks
  416.                 db      256 dup ('Stack000')    ; 2K stack for process #1
  417. MainStackEnd    label   word
  418.  
  419.             if @datasize        ; for large model, need to get definitions
  420.                 .fardata        ;  for FAR_DATA and FAR_BSS, so we can
  421.                 .fardata?       ;   make them R/W segments!
  422.             endif
  423.  
  424.                 end     NetWareVAP              ; MUST HAVE THIS!!!!
  425.